package com.mate.resp;


public enum RespResult {

    FAILURE(-1, "系统繁忙"),
    SUCCESS(0, "请求成功");

    private int resCode;
    private String message;
    private boolean success;

    // 构造方法
    RespResult(int resCode, String message) {
        this.resCode = resCode;
        this.message = message;
        this.success = (resCode == 0);
    }

    public JsonData setJson4Data(Object data) {
        return new JsonData(success, resCode, message, data);
    }

    public JsonData getJsonData() {
        return new JsonData(success, resCode, message, null);
    }

    public JsonData getJsonData(String s, boolean success) {
        return new JsonData(success, resCode, s, null);
    }

    public boolean isSuccess() {
        for (RespResult result : RespResult.values()) {
            if (result.resCode == resCode) {
                return result.isSuccess();
            }
        }
        return false;
    }
}